package edu.ustb.controller.xiumi;

import com.alibaba.fastjson.JSONObject;
import edu.ustb.utils.MakeAuthCode;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "xiumiPhone", value = "/xiumiPhone.do")
public class xiumiPhoneController extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setCharacterEncoding("UTF-8");
        String phone = request.getParameter("phone");
        String authCode = MakeAuthCode.getAuthCode(6);
        JSONObject json = new JSONObject();
        json.put("status", "true");
        json.put("message", "验证码发送成功");
        json.put("authCode", authCode);
        response.getWriter().println(json);
    }
}
